package com.gitee.zycra.future.job.common.param;

import com.gitee.zycra.future.job.common.model.JobUser;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import javax.validation.constraints.NotNull;

/**
 * @author zycra
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
public class UpdateUserParam {

    /**
     * 主键
     */
    @NotNull(message = "主键不能为空")
    private Long id;

    /**
     * 用户名
     */
    @NotNull(message = "用户名不能为空")
    private String username;

    /**
     * 权限
     * @see com.gitee.zycra.future.job.common.enums.UserAuthEnum
     */
    @NotNull(message = "权限不能为空")
    private Integer auth;

    public static JobUser convertToJobUser(UpdateUserParam updateUserParam) {
        if (updateUserParam == null) {
            return null;
        }
        return new JobUser().setId(updateUserParam.getId())
                .setUsername(updateUserParam.getUsername())
                .setAuth(updateUserParam.getAuth());
    }
}
